package cn.niit.service.impl;

import cn.niit.dao.MessageDao;
import cn.niit.entity.Message;
import cn.niit.entity.query.MessageQuery;
import cn.niit.service.MessageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 留言表 (Message)表服务实现类
 *
 * @author makejava
 * @since 2021-11-14 16:07:19
 */
@Service("messageService")
public class MessageServiceImpl implements MessageService {
    @Resource
    private MessageDao messageDao;


    @Override
    public PageInfo<Message> queryByMessage(MessageQuery messageQuery) {
        PageHelper.startPage(messageQuery.getPageNum(),messageQuery.getPageSize());
        return new PageInfo<Message>(messageDao.queryByMessage(messageQuery));
    }

    @Override
    public PageInfo<Message> queryByTeacherCode(MessageQuery messageQuery) {
        PageHelper.startPage(messageQuery.getPageNum(),messageQuery.getPageSize());
        return new PageInfo<Message>(messageDao.queryByTeacherCode(messageQuery));
    }

    @Override
    public PageInfo<Message> select(MessageQuery messageQuery) {
        PageHelper.startPage(messageQuery.getPageNum(),messageQuery.getPageSize());
        return new PageInfo<Message>(messageDao.select(messageQuery));
    }

    @Override
    public PageInfo<Message> queryByStudentCode(MessageQuery messageQuery) {
        PageHelper.startPage(messageQuery.getPageNum(),messageQuery.getPageSize());
        return new PageInfo<Message>(messageDao.queryByStudentCode(messageQuery));
    }

    @Override
    public PageInfo<Message> selectNull(MessageQuery messageQuery) {
        PageHelper.startPage(messageQuery.getPageNum(),messageQuery.getPageSize());
        return new PageInfo<Message>(messageDao.selectNull(messageQuery));
    }


    @Override
    public boolean editMessage(Message message) {
        int i = messageDao.editMessage(message);
        return i > 0;
    }

    @Override
    public Message queryMessageById(Integer id) {
        return messageDao.queryMessageById(id);
    }

    @Override
    public boolean addMessage(Message message) {
        return messageDao.addMessage(message) > 0;
    }

    @Override
    public boolean deleteMessageById(Integer id) {
        int i = messageDao.deleteMessageById(id);
        return i > 0;
    }
}